package com.du.back1.controller;

import com.du.back1.exception.CustomException;
import com.du.back1.service.EmployeeService;
import com.du.back1.utills.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class Hello {

    @Autowired
    EmployeeService employeeService;
    //get post put delete

    @GetMapping("/hello")
    public BaseResult hello() {
        return BaseResult.success("服务数据");
    }

    @GetMapping("/age")
    public BaseResult getAge() throws CustomException {
        throw new CustomException("502","报错");
    }

    @GetMapping("/map")
    public BaseResult getInfo() {
        HashMap<String, String> map = new HashMap<>();
        map.put("username", "小明");
        map.put("passWord", "admin");
        map.put("age", "12");
        return BaseResult.success(map);
    }
    @GetMapping("/getAll")
    public BaseResult getAll() {
        return BaseResult.success(employeeService.getAll());
}

}

